<template>
  <div>
    <!-- 面包屑导航 -->
      <el-breadcrumb separator-class="el-icon-arrow-right">
        <el-breadcrumb-item :to="{ path: '/welcome' }">首页</el-breadcrumb-item>
        <el-breadcrumb-item>订单管理</el-breadcrumb-item>
        <el-breadcrumb-item>订单列表</el-breadcrumb-item>
      </el-breadcrumb>
    <!-- / 面包屑导航 -->
    <!-- 表单 -->
    <el-card>
      <el-input style='width: 30%' placeholder="请输入内容" class='input-with-select'>
            <el-button slot='append' icon='el-icon-search'></el-button>
          </el-input>
    </el-card>
    <!-- 订单列表 -->
    <el-table border stripe :data='order'>
      <el-table-column type='index' label="#"></el-table-column>
      <el-table-column prop="order_number" label="订单编号"></el-table-column>
      <el-table-column prop="order_price" label="订单价格"></el-table-column>
      <el-table-column prop="pay_status" label="是否付款">
        <template slot-scope="scope">
          <el-tag v-if="scope.row.pay_status === '1'" type="success">已付款</el-tag>
          <el-tag else type="danger">未付款</el-tag>
        </template>
      </el-table-column>
      <el-table-column prop="is_send" label="是否发货"></el-table-column>
      <el-table-column label="下单时间">
        <template slot-scope="scope">
          {{scope.row.create_time | formatDate}}
        </template>
      </el-table-column>
      <el-table-column width='200' label="操作">
        <template>
          <el-button @click='orderdialogVisible = true' type="primary" size="mini">修改地址</el-button>
          <el-button @click='showExpress' type="success" size="mini">物流进度</el-button>
        </template>
      </el-table-column>
    </el-table>
    <!-- 分页 -->
    <!-- <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="currentPage4"
      :page-sizes="[100, 200, 300, 400]"
      :page-size="100"
      layout="total, sizes, prev, pager, next, jumper"
      :total="400">
    </el-pagination> -->
    <!-- 修改地址 -->
    <el-dialog
      title="修改地址"
      :visible.sync="orderdialogVisible"
      width="50%">
      <el-form ref='ordeFormRef' :model="form" label-width="80px">
        <el-form-item label="省市区/县">
          <el-cascader
            v-model="form.cityValue"
            :options="citydata"
            @change="cataesHandleChange">
          </el-cascader>
        </el-form-item>
        <el-form-item label="详细地址">
          <el-input></el-input>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="orderdialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="orderdialogVisible = false">确 定</el-button>
      </span>
    </el-dialog>
    <!-- 物流进度 -->
    <el-dialog
      title="物流进度"
      :visible.sync="experssDialogVisible"
      width="50%">
      <el-timeline :reverse="false">
        <el-timeline-item
          v-for="(item, index) in expesslist"
          :key="index"
          :timestamp="item.time">
          {{item.content}}
        </el-timeline-item>
      </el-timeline>
    </el-dialog>
  </div>
</template>

<script>
import citydata from './citydata.js'
export default {
  data () {
    return {
      // 订单列表参数
      queryData: {
        // 查询参数
        query: '',
        // 当前页码
        pagenum: 1,
        // 每页显示条数
        pagesize: 5
      },
      // 接受订单列表数据
      order: [],
      // 接受总条数
      total: 0,
      orderdialogVisible: false,
      form: {
        cityValue: []
      },
      citydata,
      experssDialogVisible: false,
      expesslist: []
    }
  },

  created () {
    this.getOrder()
  },

  methods: {
    // 获取订单列表
    async getOrder () {
      const { data: res } = await this.$axios.get('orders', {
        params: this.queryData
      })
      if (res.meta.status !== 200) return this.$message.error('获取失败!')
      this.order = res.data.goods
      this.total = res.data.total
    },
    cataesHandleChange () {},
    async showExpress () {
      this.experssDialogVisible = true
      const { data: res } = await this.$axios.get('http://localhost:8080/api/express')
      if (res.meta.status !== 200) return this.$message.error('获取数据失败!')
      this.expesslist = res.data
    }
  }
}
</script>

<style scoped lang='less'>

</style>
